package com.minminaya.source;

public class Algorithm_7 {

    public static long fibonacci(int n) {

        if (n <= 0) {
            return 0;
        }

        if (n == 1 || n == 2) {
            return 1;
        }

        long prePre = 1;
        long pre = 1;
        long current = 2;

        for (int i = 3; i <= n; i++) {
            current = prePre + pre;
            prePre = pre;
            pre = current;
        }
        return current;
    }

    public static void main(String[] args) {


        System.out.println("Hello World!");

        long tmp = Algorithm_7.fibonacci(8);
        System.out.print(tmp);
    }
}
